package com.gl.saasservice.device.controller;

import com.gl.framework.web.response.Result;
import com.gl.saasservice.device.service.DeviceService;
import com.gl.saasservice.device.vo.DeviceVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 一体机设备管理
 */
@Controller
@RequestMapping("/device")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    /**
     * 一体机设备列表
     *
     * @param token
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/deviceList")
    @ResponseBody
    public Result deviceList(@RequestHeader String token,
                             @RequestParam(defaultValue = "0") Integer pageNumber,
                             @RequestParam(defaultValue = "10") Integer pageSize) {
        return deviceService.deviceList(token, pageNumber, pageSize);
    }

    /**
     * 新增或编辑
     *
     * @param token
     * @param vo
     * @return
     */
    @PostMapping("/saveOrUpdate")
    @ResponseBody
    public Result saveOrUpdate(@RequestHeader String token,
                               @RequestBody DeviceVO vo) {
        return deviceService.saveOrUpdate(token, vo);
    }

    /**
     * 删除
     *
     * @param token
     * @param vo
     * @return
     */
    @GetMapping("/delete")
    @ResponseBody
    public Result delete(@RequestHeader String token, DeviceVO vo) {
        return deviceService.delete(token, vo);
    }

    /**
     * 设置密码
     *
     * @param token
     * @param vo
     * @return
     */
    @PostMapping("/setPwd")
    @ResponseBody
    public Result setPwd(@RequestHeader String token,
                         @RequestBody DeviceVO vo) {
        return deviceService.setPwd(token, vo);
    }


}
